package server;

/**
 * 抽象的Servlet类，自己需要实现真实的Servlet来继承它，并实现 doGet 和 doPost 方法
 * @author zhang
 */
public abstract class HttpServlet implements Servlet{


    public abstract void doGet(Request request,Response response);

    /**
     * doPost
     * @param request   请求
     * @param response  响应
     */
    public abstract void doPost(Request request,Response response);


    /**
     * 判断请求方法，并进行一个转发
     * @param request
     * @param response
     * @throws Exception
     */
    @Override
    public void service(Request request, Response response) throws Exception {
        if("GET".equalsIgnoreCase(request.getMethod())) {
            doGet(request,response);
        }else{
            doPost(request,response);
        }
    }
}
